package cn.ytian.scashier;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class YLib {
    static Scanner in = new Scanner(System.in);
   public static void pln(Object o){
        System.out.println(o);
    }
    public static void pl(Object o){
        System.out.print(o);
    }

    public static void pl(String str, Object ...args){
        System.out.printf(str,args);
    }

    public static void pln(String str, Object ...args){
       System.out.printf(str+"\n",args);
    }
    public static String Yin(){
       return in.next();
    }

    public static String YinLine(){
        in.nextLine();
       return in.nextLine();
    }

    public static int YinInt(){
        return in.nextInt();
    }

    public static void inFile(String path){
        File file = new File(path);
        if (!file.exists()){
             file.getParentFile().mkdirs();
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static boolean inFileB(String path){
        File file = new File(path);
        return file.exists();
    }

    /**
     * 时间戳转时间
     *
     * @param stamp 如：1632897997000
     */
    public static String stampToDate(String stamp) {
        String res;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        long lt = Long.parseLong(stamp);
        Date date = new Date(lt);
        res = simpleDateFormat.format(date);
        return res;
    }


    public static String getTime(){
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return formatter.format(currentTime);
    }
}
